package com.maila.xiaoaoschool.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.maila.xiaoaoschool.R;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 充值界面
 * Created by Administrator on 2017/10/27.
 */

public class RechangeActivity extends AppCompatActivity {
    @BindView(R.id.white_return_iv)
    AutoRelativeLayout whiteReturnIv;
    @BindView(R.id.et_money)
    EditText etMoney;
    @BindView(R.id.btn_rechange)
    Button btnRechange;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rechange);
        ButterKnife.bind(this);
        etMoney.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if(etMoney.getText()!=null&&etMoney.getText().length()>2){
                    btnRechange.setClickable(true);
                    btnRechange.setBackgroundResource(R.drawable.bg_rd_orange);
                }else {
                    btnRechange.setClickable(false);
                    btnRechange.setBackgroundResource(R.drawable.bg_rd_gray);
                }
            }
        });
    }

    @OnClick({R.id.white_return_iv, R.id.btn_rechange})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.white_return_iv:
                finish();
                break;
            case R.id.btn_rechange:
                break;
        }
    }
}
